<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .mask{
      position: fixed;
      left:0;
      right:0;
      top:0;
      bottom:0;
      background:rgba(0,0,0,.5);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .content{
      width:500px;
      height: 500px;
      background:#fff;

    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="showMask">点击出现弹出层</button>
    <div class="mask" @click.self="closeMask" v-show="isShow">
      <!-- <div class="content" @click.stop>
        我是弹出层内容
        <button>内容</button>
      </div> -->
      <div class="content">
        我是弹出层内容
        <button>内容</button>
      </div>
    </div>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el:'#app',
      data:{
        isShow: false
      },
      methods:{
        showMask(){
          this.isShow=true
        },
        closeMask(){
          this.isShow = false
        }
      }
    })
  </script>
</body>
</html>
